<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<%@ taglib prefix="gmms" uri="/gmms-tags"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<c:choose>
<c:when test="${loadData==null}">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>我的消息</title>
<jsp:include page="../head.jsp" />
<script language="javascript">
function del(keyId){
	xbox.confirm("您正在执行删除操作,确认吗?", function (result) {
	    if (result) {
	    	$.ajax({
				url			:"<%=path%>/message/messageAjax_deleteSender_msgAction.action",
				type 		: "POST",
				dataType 	: "json",
				data		: {
					"messageId" : keyId
				},
				success 	: function(data) {
					j_loadData($("#currentPage").val());
				},
				error		:function(){
					xbox.alert("数据正在提交，请稍候，或检查您的网络环境,确保其连接正常！");
				}
			});
	    }
	}, {
	    title: '系统提示',
	    value: '确定'
	});
 
 
}

function toAdd(){
	openModelWindow("发消息","<%=path%>/message/message_toAdd_sendAction.action");
}

function toEdit(keyId){
	openModelWindow("消息详情","<%=path%>/message/message_toEdit_showAction.action?messageId="+keyId);
}
</script>
</head>
<body>
<div class="info_right_main">

<form action="<%=path%>/message/message_queryReceiver_receiverAction.action" method="post" id="refreshForm" name="refreshForm">
	<input type="hidden" id="currentPage" name="currentPage" value="${currentPage}"/>
</form>

<div class="info_right_ctrl">
    <input class="btn" onclick="toAdd();" type="button" value="发消息" />
    
    <input class="btn" type="button" onclick="j_search(1,true);" value="更新列表" />
    <span style="font-size:13px;padding-top:15px;float:right;padding-right:30px;cursor: pointer;" onclick="operationManual(${currentMenuId})">
    	<img src="<%=path %>/images/help.png" title="帮助" />帮助
    </span>
</div>
        
<div class="info_right_main">
	<div id="gridHead">
		<table width="100%" border="0" cellspacing="0" cellpadding="0" style="TABLE-LAYOUT:fixed;">
		 	<tr height="35">
	         <td width="5%" align="center"><strong>序号</strong></td>
	         <td width="40%" align="center"><strong>消息内容</strong></td>
	         <td width="15%" align="center"><strong>发送时间</strong></td>
	         <td width="10%" align="center"><strong>接收人</strong></td>
	         <td width="10%" align="center"><strong>已读回执</strong></td>
	         <td width="10%" align="center"><strong>操作</strong></td>
	       </tr>
		</table>
	</div>
	<div style="overflow:auto;display:none;" id="divGrid">
	</div>
	<table border="0" cellspacing="0" cellpadding="0" width="100%" id="tablePager"></table>
</div> 
  
</div>


</body>
</html>
</c:when>
<c:otherwise>
	<table id="gridTable" width="100%" border="0" cellspacing="0" cellpadding="0">
	       <c:forEach items="${list}" var="message" varStatus="status">
				<tr align='center' bgcolor="#FFFFFF" onMouseMove="javascript:this.bgColor='#f1f1f1';" onMouseOut="javascript:this.bgColor='#FFFFFF';" height="30" >
					<td>${status.index+1}</td>
					<td>${message.messageContent}</td>
					<td><fmt:formatDate value="${message.sendDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
					<td>${message.receiver.realName}</td>
					<td>
						<c:if test="${message.messageState eq 0}"><font color="orange">对方未读</font></c:if>
						<c:if test="${message.messageState eq 1}"><font color="green">对方已读</font></c:if>
					</td>
					<td>
						<span style="width:140px;"><input class="btn" onclick="toEdit(${message.messageId});" type="button" value="查看" /></span>
						 <span style="width:140px;"><input class="btn" onclick="del(${message.messageId});" type="button" value="删除" /></span>
					</td>
				</tr>
			</c:forEach>
			<tr align="right" bgcolor="#f1f1f1">
				<td height="30" colspan="9" align="right">
				 <!-- 分页 -->
				 <gmms:pages currentPage="%{currentPage}" totalPage="%{totalPage}" />
				</td>
			</tr>
     </table>
	
</c:otherwise>
</c:choose>